package main


// Definition for singly-linked list.
type ListNode struct {
    Val int
    Next *ListNode
}


func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode {
    val := l1.Val + l2.Val
    
    if l1.Next != nil {
        l1 = l1.Next
    } else {
        l1 = new(ListNode)
    }
    if l2.Next != nil {
        l2 = l2.Next
    } else {
        l2 = new(ListNode)
    }

    l1.Val += val/10
    var next *ListNode
    if l1.Val!=0 || l1.Next!=nil || l2.Val!=0 || l2.Next!=nil {
        next = addTwoNumbers(l1, l2)
    }

    ret := new(ListNode)
    ret.Val = val%10
    ret.Next = next
    return ret
}
